﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DynamicType.aspx.cs" Inherits="Catering.Catering_Page.system.DynamicType" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/zhezhao.js" type="text/javascript"></script>
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <link href="../../Style/sysData.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        //显示添加
        function Add() {
            $("#btnEdit").hide();
            $("#btnAdd").show();
            divshow("main", "bg");
        }

        //显示修改
        function Edit(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "DynamicType.aspx/Get",
                data: "{'cid':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_CName").val(data.d[0]);
                    $("#txt_Back").val(data.d[1]);
                    $("#btnEdit").show();
                    $("#btnAdd").hide();
                    divshow("main", "bg");
                }
            });
        }

        //添加数据
        function btn_Add() {
            var txt_CName = $("#txt_CName").val();
            var txt_Back = $("#txt_Back").val();

            $.ajax({
                type: "Post",
                url: "DynamicType.aspx/Add",
                data: "{'Name':'" + txt_CName + "','Back':'" + txt_Back + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'DynamicType.aspx';
                    }
                }
            });
        }

        //修改数据
        function btn_Edit() {
            var txt_CName = $("#txt_CName").val();
            var txt_Back = $("#txt_Back").val();
            var cid = $("#HidID").val();

            $.ajax({
                type: "Post",
                url: "DynamicType.aspx/Edit",
                data: "{'cid':'" + cid + "','Name':'" + txt_CName + "','Back':'" + txt_Back + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = 'DynamicType.aspx';
                    }
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="HidID" runat="server" />
    <div class="btn_list">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td align="right">
                    <input type="button" class="input_btn_a" value="添加" onclick="Add()" style="margin-right: 10px;" />
                </td>
            </tr>
        </table>
    </div>
    <div class="data_css">
        <table width="100%" border="1" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th>
                        名称
                    </th>
                    <th>
                        备注
                    </th>
                    <th>
                        编辑
                    </th>
                    <th>
                        删除
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="Rep_OperationArea" runat="server" OnItemCommand="Rep_ItemCommand">
                    <ItemTemplate>
                        <tr>
                            <td>
                                <%#Eval("Name")%>
                            </td>
                            <td>
                                <%#Eval("Contents")%>
                            </td>
                            <td>
                                <img src="../../Images/file.gif" onclick="Edit('<%#Eval("id")%>')" style="cursor: pointer;" />
                            </td>
                            <td>
                                <asp:ImageButton ID="img_btn" runat="server" ImageUrl="../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                    CommandArgument='<%#Eval("id")%>' CommandName="del" />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
    <!--弹出层-->
    <div id="bg" class="bg">
    </div>
    <div id="main" class="center_div" style="width: 400px; height: 150px; padding: 0px;
        margin-top: -100px;">
        <div class="div_0207" style="width: 380px; margin: 5px 0px 0px 10px;">
            <h1>
                <img src="../../Images/cp_h1_03.gif" />添加作业区信息</h1>
            <table width="100%">
                <tr>
                    <td>
                        名称:
                    </td>
                    <td colspan="3">
                        <asp:TextBox ID="txt_CName" runat="server" CssClass="input_bg"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        备注：
                    </td>
                    <td colspan="3">
                        <asp:TextBox ID="txt_Back" runat="server" TextMode="MultiLine" CssClass="input_bg"
                            Style="width: 98%; height: 40px;"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <table width="100%">
                <tr>
                    <td align="right">
                        <input type="button" id="btnAdd" onclick="btn_Add()" class="input_btn_a" value="提交" />
                        <input type="button" id="btnEdit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                    </td>
                    <td>
                        <input type="button" id="but_Close" onclick='divhidel("main","bg")' class="input_btn_a"
                            value="关闭" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>
